/**
 * 
 */
package org.arpit.masteringextjs.domain;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.ManyToMany;
import javax.persistence.OneToOne;
import javax.persistence.Transient;

import org.arpit.masteringextjs.jsonserializer.ParentToStringSerializer;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonSerialize;

/**
 * @author Arpit.Rathore
 *
 */
@Entity
public class Menu extends BaseEntity{

	private String text;
	private String iconCls;
	private String className;
	
	@Transient
	private boolean Leaf;
	
	@OneToOne
	private Menu parent;

	@ManyToMany(mappedBy="menus")
	private Set<Groups> groups = new HashSet<>();
	
	@Transient
	private Object items;
	
	@JsonIgnore
	public Set<Groups> getGroups() {
		return groups;
	}

	public void setGroups(Set<Groups> groups) {
		this.groups = groups;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public String getIconCls() {
		return iconCls;
	}

	public void setIconCls(String iconCls) {
		this.iconCls = iconCls;
	}

	public String getClassName() {
		return className;
	}

	public void setClassName(String className) {
		this.className = className;
	}

	@JsonSerialize(using = ParentToStringSerializer.class, as=Menu.class)
	@JsonProperty("parent_id")
	public Menu getParent() {
		return parent;
	}

	public void setParent(Menu parent) {
		this.parent = parent;
	}

	public boolean isLeaf() {
		return Leaf;
	}

	public void setLeaf(boolean leaf) {
		Leaf = leaf;
	}

	public Object getItems() {
		return items;
	}

	public void setItems(Object items) {
		this.items = items;
	}
}
